package cn.lj.base.Controller;

import cn.lj.base.service.IVerifycodeService;
import cn.lj.base.util.AjaxResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
@Api(tags = "获取手机验证码",description = "获取手机验证码接口")
public class SmsCodeController {
    /*注入service层对象*/
    @Autowired
    private IVerifycodeService verifycodeService;
    @PostMapping("/smsCode")
    public AjaxResult getCode(@RequestBody Map<String,String> map){
        String phone = map.get("phone");
        String type = map.get("type");
        try {
            verifycodeService.smsCode(phone,type);
            return AjaxResult.me();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.me().setAjaxResult(e.getMessage());
        }
    }
}
